package com.dynamixsoftware.printershare.snmp;

import java.util.StringTokenizer;

public class SNMPIPAddress
  extends SNMPOctetString
{
  public SNMPIPAddress()
  {
    this.tag = 64;
    this.data = new byte[4];
    for (int i = 0; i < 4; i++) {
      this.data[i] = 0;
    }
  }
  
  public SNMPIPAddress(String paramString)
    throws SNMPBadValueException
  {
    this.tag = 64;
    this.data = parseIPAddress(paramString);
  }
  
  public SNMPIPAddress(byte[] paramArrayOfByte)
    throws SNMPBadValueException
  {
    this.tag = 64;
    if (paramArrayOfByte.length == 4)
    {
      this.data = paramArrayOfByte;
      return;
    }
    throw new SNMPBadValueException(" IPAddress: bad BER encoding supplied to set value ");
  }
  
  private byte[] parseIPAddress(String paramString)
    throws SNMPBadValueException
  {
    int i;
    try
    {
      StringTokenizer localStringTokenizer1 = new StringTokenizer(paramString, " .");
      i = 0;
      while (localStringTokenizer1.hasMoreTokens())
      {
        i++;
        localStringTokenizer1.nextToken();
      }
      if (i == 4) {
        break label58;
      }
    }
    catch (NumberFormatException localNumberFormatException)
    {
      throw new SNMPBadValueException(" IPAddress: invalid component supplied to set value ");
    }
    throw new SNMPBadValueException(" IPAddress: wrong number of components supplied to set value ");
    label58:
    byte[] arrayOfByte = new byte[i];
    StringTokenizer localStringTokenizer2 = new StringTokenizer(paramString, " .");
    for (int j = 0; j < i; j++)
    {
      int k = Integer.parseInt(localStringTokenizer2.nextToken());
      if ((k < 0) || (k > 255)) {
        throw new SNMPBadValueException(" IPAddress: invalid component supplied to set value ");
      }
      arrayOfByte[j] = ((byte)k);
    }
    return arrayOfByte;
  }
  
  public void setValue(Object paramObject)
    throws SNMPBadValueException
  {
    if (((paramObject instanceof byte[])) && (((byte[])paramObject).length == 4))
    {
      this.data = ((byte[])paramObject);
      return;
    }
    if ((paramObject instanceof String))
    {
      this.data = parseIPAddress((String)paramObject);
      return;
    }
    throw new SNMPBadValueException(" IPAddress: bad data supplied to set value ");
  }
  
  public String toString()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    if (this.data.length > 0)
    {
      int i = this.data[0];
      if (i < 0) {
        i += 256;
      }
      localStringBuffer.append(i);
      for (int j = 1; j < this.data.length; j++)
      {
        int k = this.data[j];
        if (k < 0) {
          k += 256;
        }
        localStringBuffer.append(".");
        localStringBuffer.append(k);
      }
    }
    return localStringBuffer.toString();
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.snmp.SNMPIPAddress
 * JD-Core Version:    0.7.0.1
 */